/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
func isSameTree(p *TreeNode, q *TreeNode) bool {
    if p == nil && q == nil {
        return true
    } else if p == nil || q == nil {
        return false
    } else if p.Val != q.Val {
        return false
    }
    isLeftSame := isSameTree(q.Left, p.Left)
    isRightSame := isSameTree(q.Right, p.Right)
    return isLeftSame && isRightSame

}